import { instance } from '@/utils/request'

export const getCartList = () => {
  return instance.get('/cart/list')
}

export const getCartNum = () => {
  return instance.get('/cart/total')
}

export const addCart = ({
  goodsId,
  goodsNum,
  goodsSkuId = ''
}) => {
  // console.log(`添加购物车参数 ${goodsId}, ${goodsNum}, ${goodsSkuId}`)
  return instance.post('/cart/add', {
    goodsId,
    goodsNum,
    goodsSkuId
  })
}

export const updateCart = ({
  goodsId,
  goodsNum,
  goodsSkuId = ''
}) => {
  return instance.post('/cart/update', {
    goodsId,
    goodsNum,
    goodsSkuId
  })
}

export const clearCart = ({
  cartIds
}) => {
  return instance.post('/cart/clear', {
    cartIds
  })
}
